<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>缓存全局变量</title>
    </head>
    <body>
        <input type="button" value="btn" id="btn1" />
        <input type="button" value="btn" id="btn2" />
        <input type="button" value="btn" id="btn3" />
        <p>111</p>
        <input type="button" value="btn" id="btn4" />
        <input type="button" value="btn" id="btn5" />
        <p>222</p>
        <input type="button" value="btn" id="btn6" />
        <input type="button" value="btn" id="btn7" />
        <input type="button" value="btn" id="btn8" />
        <p>333</p>
        <input type="button" value="btn" id="btn9" />
        <script>
            function getBtn() {
                let btn1 = document.getElementById("btn1");
                let btn3 = document.getElementById("btn3");
                let btn5 = document.getElementById("btn5");
                let btn7 = document.getElementById("btn7");
                let btn9 = document.getElementById("btn9");
            }
            function getBtn2() {
                let obj = document;
                let btn1 = obj.getElementById("btn1");
                let btn3 = obj.getElementById("btn3");
                let btn5 = obj.getElementById("btn5");
                let btn7 = obj.getElementById("btn7");
                let btn9 = obj.getElementById("btn9");
            }
        </script>
    </body>
</html>
